import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.Future;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author zhangdi
 * @version 1.0
 * @date 2022.3.7 17:33
 */
public class TestThread {
    ThreadLocal<String> nameTL = new ThreadLocal<>();

    public static void main(String[] args) throws InterruptedException {
        TestThread testThread = new TestThread();
        ZDThreadPoolExecutor threadPoolExecutor = new ZDThreadPoolExecutor(2);
        Test1 test1 = new Test1("t1");
        threadPoolExecutor.exec(test1, 6, 6, TimeUnit.SECONDS);

        Test2 test2 = new Test2("t2");
        threadPoolExecutor.exec(test2, 3, 3, TimeUnit.SECONDS);

        int loop = 0;
        while (true){
            if(loop == 2) {
                threadPoolExecutor.stop("t1");
            }
            if(loop == 6) {
                threadPoolExecutor.stop("t2");
            }
            Thread.sleep(1000);
            System.out.println("task:"+threadPoolExecutor.getTaskCount() + " completed:" + threadPoolExecutor.getCompletedTaskCount() + " active:" +threadPoolExecutor.getActiveCount());
            ++loop;
        }
    }
}
